﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Site.master" AutoEventWireup="true" CodeBehind="QLDanhMuc.aspx.cs" Inherits="Indochinaodyssey.Admin.QLDanhMuc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 4px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<asp:Label ID="Label1" runat="server" Text="Quản lý danh mục" Font-Bold="True" 
        Font-Size="15pt"></asp:Label>
&nbsp;<asp:MultiView ID="mtvQLDanhMuc" runat="server" ActiveViewIndex="0">
        <asp:View ID="viewTable" runat="server">
            <table class="style1">
                <tr>
                    <td>
                        &nbsp;</td>
                    <td align="right">
                        <asp:Label ID="lblMes" runat="server"></asp:Label>
                        <asp:Button ID="btnCreate" runat="server" onclick="btnCreate_Click" 
                            Text="Tạo danh mục mới" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:GridView ID="grvDanhMuc" runat="server" AutoGenerateColumns="False" 
                            BorderStyle="None" CellPadding="4" DataKeyNames="ID" 
                            DataSourceID="SqlDataSourceDanhMuc" ForeColor="#333333" GridLines="None" 
                            Width="100%">
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            <Columns>
                                <asp:BoundField DataField="ID" HeaderText="STT" InsertVisible="False" 
                                    ReadOnly="True" SortExpression="ID">
                                <ItemStyle BackColor="#FBAD44" HorizontalAlign="Center" Width="50px" />
                                </asp:BoundField>
                                <asp:BoundField ApplyFormatInEditMode="True" DataField="TenDanhMuc" 
                                    HeaderText="TÊN DANH MỤC" SortExpression="TenDanhMuc">
                                <ItemStyle HorizontalAlign="Center" Width="250px" />
                                </asp:BoundField>
                                <asp:BoundField DataField="TYPECODE" HeaderText="KIỂU DANH MỤC" 
                                    SortExpression="TYPECODE">
                                <ItemStyle HorizontalAlign="Center" />
                                </asp:BoundField>
                                <asp:BoundField DataField="MoTa" HeaderText="MÔ TẢ" SortExpression="MoTa">
                                <ItemStyle Width="45%" />
                                </asp:BoundField>
                                <asp:TemplateField HeaderText="ACTION">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="btnSua" runat="server" onclick="btnSua_Click">Sửa</asp:LinkButton>
                                        &nbsp;<asp:HiddenField ID="hfID" runat="server" Value='<%# Eval("ID") %>' />
                                        &nbsp;<asp:LinkButton ID="btnXoa" runat="server" onclick="btnXoa_Click" onclientclick="return confirm('Bạn chắc chắn muốn xóa?');">Xóa</asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <EditRowStyle BackColor="#999999" />
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <SelectedRowStyle BackColor="#006699" Font-Bold="True" ForeColor="#333333" />
                            <SortedAscendingCellStyle BackColor="#E9E7E2" />
                            <SortedAscendingHeaderStyle BackColor="#506C8C" />
                            <SortedDescendingCellStyle BackColor="#FFFDF8" />
                            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                        </asp:GridView>
                        <asp:SqlDataSource ID="SqlDataSourceDanhMuc" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            
                            SelectCommand="SELECT dbo.tblDanhMuc.ID, dbo.tblDanhMuc.TenDanhMuc, dbo.tblDanhMuc.TypeID, dbo.tblDanhMuc.MoTa, dbo.tblType.TYPECODE FROM dbo.tblDanhMuc INNER JOIN dbo.tblType ON dbo.tblDanhMuc.TypeID = dbo.tblType.ID ORDER BY dbo.tblDanhMuc.ID">
                        </asp:SqlDataSource>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        &nbsp;</td>
                </tr>
            </table>
        </asp:View>
        <asp:View ID="viewCreate" runat="server">
            <table class="style1">
                <tr>
                    <td>
                        &nbsp;</td>
                    <td align="right">
                        &nbsp;</td>
                    <td align="right">
                        <asp:Button ID="btnBack" runat="server" Text="Quay lại" 
                            onclick="btnCancel_Click" CausesValidation="False" />
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                    <td align="right" valign="top">
                        Tên danh mục:</td>
                    <td>
                        <asp:TextBox ID="txtName" runat="server" Width="736px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                            ControlToValidate="txtName" ErrorMessage="(*)" ForeColor="#FF5050"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                    <td align="right" valign="top">
                        Kiểu danh mục:</td>
                    <td>
                        <asp:DropDownList ID="cbxType" runat="server" DataSourceID="SqlDataSourceType" 
                            DataTextField="TYPECODE" DataValueField="ID" Width="250px">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SqlDataSourceType" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                            SelectCommand="SELECT * FROM [tblType]"></asp:SqlDataSource>
                        (* Lưu ý : kiểu danh mục không thể sửa sau khi được tạo.)</td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                    <td align="right" valign="top">
                        Mô tả:</td>
                    <td>
                        <asp:TextBox ID="txtMota" runat="server" Height="64px" TextMode="MultiLine" 
                            Width="746px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                            ControlToValidate="txtMota" ErrorMessage="(*)" ForeColor="#FF5050"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                    <td align="right" valign="top">
                        &nbsp;</td>
                    <td>
                        <asp:Button ID="btnSave" runat="server" onclick="btnSave_Click" 
                            Text="Tạo danh mục" />
                        &nbsp;<asp:Button ID="btnCancel" runat="server" Text="Hủy" Width="116px" 
                            onclick="btnCancel_Click" CausesValidation="False" />
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;</td>
                    <td align="right" valign="top">
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
            </table>
        </asp:View>
        <asp:View ID="viewEdit" runat="server">
         <table class="style1">
                <tr>
                    <td class="style2">
                        &nbsp;</td>
                    <td align="right">
                        &nbsp;</td>
                    <td align="right">
                        <asp:HiddenField ID="hfIDEdit" runat="server" />
                        <asp:Button ID="Button1" runat="server" Text="Quay lại" 
                            onclick="btnCancel_Click" />
                    </td>
                </tr>
                <tr>
                    <td class="style2">
                        &nbsp;</td>
                    <td align="right" valign="top">
                        Tên danh mục:</td>
                    <td>
                        <asp:TextBox ID="txtNameEdit" runat="server" Width="736px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style2">
                        &nbsp;</td>
                    <td align="right" valign="top">
                        Mô tả:</td>
                    <td>
                        <asp:TextBox ID="txtMoTaEdit" runat="server" Height="64px" TextMode="MultiLine" 
                            Width="746px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style2">
                        &nbsp;</td>
                    <td align="right" valign="top">
                        &nbsp;</td>
                    <td>
                        <asp:Button ID="btnEdit" runat="server" onclick="btnEdit_Click" 
                            Text="Sửa thông tin" />
                        &nbsp;<asp:Button ID="btnCancelEdit" runat="server" Text="Hủy" Width="116px" 
                            onclick="btnCancel_Click" />
                    </td>
                </tr>
                <tr>
                    <td class="style2">
                        &nbsp;</td>
                    <td align="right" valign="top">
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                </tr>
            </table>
        </asp:View>
    </asp:MultiView>
</asp:Content>
